package com.snake.springboot.custom.controller.goods;

import com.snake.springboot.custom.api.request.bill.BillStrgGoodsPlaceModel;
import com.snake.springboot.custom.api.request.goods.CustStryGoodsQuery;
import com.snake.springboot.custom.api.request.page.PageQuery;
import com.snake.springboot.custom.api.response.bill.BillRsp;
import com.snake.springboot.custom.api.response.goods.CustStryGoodsRsp;
import com.snake.springboot.custom.api.service.goods.CustStryGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.snake.common.result.ResponseResult;
import org.snake.common.result.ResponseResultFactory;
import org.snake.common.result.ReturnList;
import org.snake.common.validate.Create;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>商户策略商品-购买记录
 * 类{@code CustStryGoods} </br>
 * 创建时间2025/3/27 18:14
 *
 * @author yangxt
 * @see
 */
@Api(tags = "账单策略商品-购买策略商品详情")
@RestController
@RequestMapping("/bill/stry-goods")
public class CustStryGoodsController {

    private CustStryGoodsService goodsService;
    @Autowired
    public CustStryGoodsController(CustStryGoodsService goodsService) {
        this.goodsService = goodsService;
    }


    @ApiOperation("下单")
    @PostMapping("/place-order")
    public ResponseResult<BillRsp> placeOrder(
            @ApiParam(name = "接口入参", value = "传入json格式", required = true)
            @RequestBody @Validated({Create.class}) BillStrgGoodsPlaceModel model) {
        BillRsp result = goodsService.placeOrder(model);
        return ResponseResultFactory.ucc("下单成功！", result);
    }

    @ApiOperation("查询列表")
    @PostMapping("/list")
    public ResponseResult<ReturnList<CustStryGoodsRsp>> queryCustStryGoodsList(
            @ApiParam(name = "查询条件", value = "传入json类型", required = true)
            @RequestBody PageQuery<CustStryGoodsQuery> params) {
        ReturnList<CustStryGoodsRsp> result = goodsService.queryCustStryGoodsList(params);
        return ResponseResultFactory.ucc("查询成功！", result);
    }

}
